package com.xing.service.wechatui.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xing.application.service.ui.HomeService;
import xing.domain.ui.Banner;
import xing.infrastructure.data.CallResult;

import java.util.List;

/*******************************************************************************************
 * 类描述：  
 *
 * @author: dustin
 * @date: 2017-11-10 13:21
 * @Description:
 * @version 1.0
 *
 *
 * Version    Date       ModifiedBy                 Content  
 * -------- ---------    ----------         ------------------------  
 * 1.0      2017/11/10     dst                               
 *******************************************************************************************
 */
@Api(value = "首页相关方法",description = "")
@RestController
@RequestMapping("/home")
public class HomeController {
    @Autowired
    HomeService homeService;

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @ApiOperation(value="获取banner列表", notes="",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping("/banner")
    public CallResult getBanner(){
        try {
            List<Banner> list= homeService.getBannerList();
            return CallResult.ok(list);
        } catch (Exception e) {
            logger.error("获取banner列表失败",e);
            return CallResult.error("获取banner列表失败");
        }
    }
}
